package com.party.core.model.member;

import com.party.common.utils.DateUtils;

/**
 * Created by wei.li
 *
 * @date 2017/9/13 0013
 * @time 14:56
 */

@SuppressWarnings("all")
public class CopartnerAnalyzeQuery extends CopartnerAnalyze {

    //开始时间
    private String createStart;

    //结束时间
    private String createEnd;

    //时间类型
    private Integer timeType;

    //排序
    private Integer sort;

    private String option;

    public String getCreateStart() {
        return createStart;
    }

    public void setCreateStart(String createStart) {
        this.createStart = createStart;
    }

    public String getCreateEnd() {
        return createEnd;
    }

    public void setCreateEnd(String createEnd) {
        this.createEnd = createEnd;
    }

    public Integer getTimeType() {
        return timeType;
    }

    public void setTimeType(Integer timeType) {
        this.timeType = timeType;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public String getOption() {
        return option;
    }

    public void setOption(String option) {
        this.option = option;
    }

    public void transToDate(CopartnerAnalyzeQuery copartnerAnalyzeQuery){
        if (null != copartnerAnalyzeQuery.getTimeType()
                && !copartnerAnalyzeQuery.getTimeType().equals(0)
                && !copartnerAnalyzeQuery.getTimeType().equals(5)) {
            String now = DateUtils.todayDate();
            String endTime = DateUtils.todayDate();
            String startTime = null;
            if (copartnerAnalyzeQuery.getTimeType().equals(1)) {
                startTime = now;
            } else if (copartnerAnalyzeQuery.getTimeType().equals(2)) {
                startTime = DateUtils.formatDate(DateUtils.addDay(now, -1));
                endTime = startTime;
            } else if (copartnerAnalyzeQuery.getTimeType().equals(3)) {
                startTime = DateUtils.formatDate(DateUtils.getFirstDayOfWeek(0));
                endTime = DateUtils.formatDate(DateUtils.getLastDayOfWeek(0));
            } else if (copartnerAnalyzeQuery.getTimeType().equals(4)) {
                startTime = DateUtils.formatDate(DateUtils.getFirstDayOfMonth(0));
                endTime = DateUtils.formatDate(DateUtils.getLastDayOfMonth(0));
            }
            copartnerAnalyzeQuery.setCreateStart(startTime);
            copartnerAnalyzeQuery.setCreateEnd(endTime);
        }
    }
}
